import 'package:flutter/material.dart';

class TextAndTypeRoute extends StatelessWidget {
  // 声明文本样式
  final textStyle = const TextStyle(
    fontFamily: 'OpenSans',
  );

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return new Scaffold(
      appBar: new AppBar(
        title: new Text('文本及样式'),
      ),
      body: new Center(
        child: new Column(
          children: <Widget>[
            Text(
              'hello world!',
              textAlign: TextAlign.center,
              textScaleFactor: 2.0,
            ),
            Text(
              "Hello world! I'm Jack. " * 2,
              maxLines: 1,
              overflow: TextOverflow.ellipsis,
              textScaleFactor: 2.0,
            ),
            Text(
              'hello world',
              style: TextStyle(
                color: Colors.blue,
                fontSize: 28.0,
                height: 1.2,
                fontFamily: "OpenSans",
                background: new Paint()..color = Colors.yellow,
                decoration: TextDecoration.underline,
                decorationStyle: TextDecorationStyle.dashed,
              ),
            ),
            DefaultTextStyle(
              //1.设置文本默认样式
              style: TextStyle(
                color: Colors.red,
                fontSize: 20.0,
              ),
              textAlign: TextAlign.left,
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: <Widget>[
                  Text("hello world"),
                  Text("I am Jack"),
                  Text(
                    "I am Jack",
                    style: TextStyle(
                        inherit: false, //2.不继承默认样式
                        color: Colors.grey),
                  ),
                ],
              ),
            ),
            Text(
              'TextType',
              textScaleFactor: 2,
              style: textStyle,//使用前面声明的文本样式
            )
          ],
        ),
      ),
    );
  }
}
